<?php
/*
	我的下线
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
$member=$this->model('member')->checkmember();
if($_RQ['op']=='main'){
	if(!$this->setting['isopen']){
		exi('未开启分销！','error');
	}
	$return['setting']=$this->plugin_setting('page');
	$return['agent_num']=pdo_count('jy_scrm_member',array('merchid'=>$_SESSION['onemerchid'],'workerid'=>$member['id']));
	$return['params']=array('page'=>1,'level'=>1);
	$return['psize']=20;
	$return['list']=array();
	set_html('tabs',$return['setting']['agent_tagent']?:'我的团');
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'workerid'=>$_SESSION['workerid']);
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		
	);
	$list=pdo_getlist('jy_scrm_member',$parameter);
	if(!$list){
		exi('none');
	}
	foreach($list as &$item){
		$item['moneycount']=pdo_getsum('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$_SESSION['onemerchid'],'mid'=>$item['mid'],'ispay'=>1),'price');
		$item['ordercount']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$_SESSION['onemerchid'],'mid'=>$item['mid'],'ispay'=>1));
		$item['createtime']=date('Y-m-d',$item['createtime']);
	}
	exi($list);
}
?>